<template>
  <div id="app">
    <Header />
    <main class="main-content">
      <router-view />
    </main>
  </div>
</template>

<script>
import Header from './components/Header.vue'
import { useUserStore } from '@/stores/user'

export default {
  name: 'App',
  components: {
    Header
  },
  setup() {
    const userStore = useUserStore()
    
    // 应用启动时检查认证状态
    userStore.checkAuth()
    
    console.log('App 初始化完成')
    console.log('初始用户状态:', userStore.user)
    console.log('localStorage user:', localStorage.getItem('user'))
    
    return { userStore }
  },
  mounted() {
    console.log('App 组件挂载完成')
    console.log('当前用户状态:', this.userStore.user)
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  background-color: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

#app {
  min-height: 100vh;
}

.main-content {
  min-height: calc(100vh - 80px);
  padding-top: 70px; /* 添加这个，因为Header是fixed定位，高度70px */
}

/* 页面通用样式 */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.page-title {
  text-align: center;
  margin-bottom: 2rem;
  color: #333;
}

/* 表单通用样式 */
.form-container {
  max-width: 400px;
  margin: 0 auto;
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.form-title {
  text-align: center;
  margin-bottom: 2rem;
  color: #333;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

.form-input:focus {
  outline: none;
  border-color: #007bff;
}

.form-button {
  width: 100%;
  padding: 12px;
  background: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

.form-button:hover:not(:disabled) {
  background: #0056b3;
}

.form-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.form-links {
  text-align: center;
  margin-top: 1rem;
}

.form-link {
  color: #007bff;
  text-decoration: none;
}

.form-link:hover {
  text-decoration: underline;
}

.error-message {
  color: #dc3545;
  background: #f8d7da;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 1rem;
  text-align: center;
}

.success-message {
  color: #155724;
  background: #d4edda;
  padding: 10px;
  border-radius: 4px;
  margin-bottom: 1rem;
  text-align: center;
}
</style>